WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
state_angle.h
Go to the documentation of this file.
1// WOLF - Copyright (C) 2020-2026
2// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
3// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
4// Joan Vallvé Navarro (jvallve@iri.upc.edu)
5// All rights reserved.
6//
7// This file is part of WOLF: http://www.iri.upc.edu/wolf
8// WOLF is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License version 3
10// as published by the Free Software Foundation.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once
20
23
24namespace wolf
25{
28class StateAngle : public StateBlock
29{
30 public:
33 StateAngle(double _angle, bool _fixed = false, bool _transformable = true);
34
37 StateAngle(const Eigen::VectorXd& _angle, bool _fixed = false, bool _transformable = true);
38
41 static Eigen::VectorXd Identity();
42
44
45 ~StateAngle() override;
46
47 virtual void transform(const VectorComposite& _transformation) override;
48};
49
50inline StateAngle::StateAngle(double _angle, bool _fixed, bool _transformable)
51 : StateBlock("StateAngle", 1, _fixed, std::make_shared<LocalParametrizationAngle>(), _transformable)
52{
53 state_(0) = pi2pi(_angle);
54}
55
56inline StateAngle::StateAngle(const Eigen::VectorXd& _angle, bool _fixed, bool _transformable)
57 : StateBlock("StateAngle", 1, _fixed, std::make_shared<LocalParametrizationAngle>(), _transformable)
58{
59 if (_angle.size() != 1) throw std::runtime_error("The angle state vector must be of size 1!");
60
61 state_(0) = pi2pi(_angle(0));
62}
63
64inline Eigen::VectorXd StateAngle::Identity()
65{
66 return Eigen::VectorXd::Zero(1);
67}
68
70{
71 //
72}
73
74inline void StateAngle::transform(const VectorComposite& _transformation)
75{
76 if (isTransformable()) setState(_transformation.at('O') + getState()); // 2D rotation is a sum of angles
77}
78
79} /* namespace wolf */
Local parametrization of an angle: increments are added and the result wrapped to [-pi,...
Definition: local_parametrization_angle.h:29
State block of an angle (2D orientation), wrapped to [-pi, pi].
Definition: state_angle.h:29
~StateAngle() override
Definition: state_angle.h:69
static Eigen::VectorXd Identity()
Returns the identity element (zero angle)
Definition: state_angle.h:64
StateAngle(double _angle, bool _fixed=false, bool _transformable=true)
Constructor from an angle.
Definition: state_angle.h:50
WOLF_STATE_BLOCK_CREATE(StateAngle)
virtual void transform(const VectorComposite &_transformation) override
Transforms the state to another reference frame (if transformable)
Definition: state_angle.h:74
State block: a state vector of a variable of the nonlinear optimization.
Definition: state_block.h:73
bool isTransformable() const
Returns whether the state block can be transformed to another reference frame.
Definition: state_block.h:235
void setState(const Eigen::VectorXd &_state, const bool _notify=true)
Sets the state vector.
Definition: state_block.cpp:25
Eigen::VectorXd getState() const
Returns the state vector.
Definition: state_block.h:322
Eigen::VectorXd state_
State vector storing the state values.
Definition: state_block.h:80
Composite of state vectors.
Definition: vector_composite.h:29
Definition: jet.h:1355
Definition: capture_base.h:23
T pi2pi(const T &_angle)
Returns the angle wrapped to [-pi, pi].
Definition: rotations.h:33